import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'

Vue.use(VueRouter)

const routes: Array<RouteConfig> = [
  {
    path: '/',
    redirect: '/home'
  },{
    path: '/home',
    name: 'home',
    component: () => import('../views/main/home.vue')
  },{
    path: '/login',
    name: 'Login',
    component: () => import('../views/main/login.vue')
  },{
    path: '/permission',
    name: 'Premission',
    component: () => import('../views/operator/permission.vue')
  },{
    path: '/dictionary',
    name: 'Dictionary',
    component: () => import('../views/operator/dictionary.vue')
  },{
    path: '/buffer',
    name: 'Buffer',
    component: () => import('../views/operator/buffer.vue')
  },{
    path: '/status',
    name: 'Status',
    component: () => import('../views/operator/status.vue')
  },{
    path: '/user',
    name: 'User',
    component: () => import('../views/sys/user.vue')
  },{
    path: '/role',
    name: 'Role',
    component: () => import('../views/sys/role.vue')
  },{
    path: '/system_log',
    name: 'SystemLog',
    component: () => import('../views/sys/log.vue')
  }
]

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
  routes
})

router.afterEach((to, from) => {
  // ...
})
export default router
